<template>
  <div class="q-pa-md">
    <pre class="q-ma-none container">{{ scrollInfo }}</pre>
    <t-scroll-observer scroll-target=".content" @scroll="onScroll" />
    <div class="text">
      <span>我是潘启宝</span>
      <span>我是潘启宝</span>
      <span>我是潘启宝</span>
      <span>我是潘启宝</span>
      <span>我是潘启宝</span>
      <span>我是潘启宝</span>
      <span>我是潘启宝</span>
    </div>
  </div>
</template>

<script>
  import { ref } from 'vue';

  export default {
    setup() {
      const scrollInfo = ref({});

      return {
        scrollInfo,
        onScroll(info) {
          scrollInfo.value = info;
        },
      };
    },
  };
</script>

<style lang="scss" scoped>
  .q-pa-md {
    height: 2000px;

    .container {
      font-size: 10px;
      position: sticky;
      top: 0;
    }

    .text {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      text-align: center;
      height: 100%;
    }
  }
</style>
